Skip to content

test(integrations): Add unit tests for Integrations API client - #2821

Draft
vikramlc-cognite wants to merge 1 commit into
integrations-part2.1-core-api-implfrom
integrations-part2.2-core-api-tests
Draft

test(integrations): Add unit tests for Integrations API client#2821
vikramlc-cognite wants to merge 1 commit into
integrations-part2.1-core-api-implfrom
integrations-part2.2-core-api-tests

Conversation

@vikramlc-cognite

Copy link
Copy Markdown

Summary

Adds unit tests (mocked HTTP) for IntegrationsAPI's CRUD methods and the Tasks, Errors, Config, and Actions sub-APIs implemented in #2820, plus retry-idempotency coverage in test_api_client.py.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor (no functional change)
  • Documentation update
  • Chore / tooling / CI

What changed

  • tests/tests_unit/test_api/test_integrations/test_integrations.py — list/create/retrieve/update/delete, including the cdf-version beta header assertion.
  • test_actions.py, test_config.py, test_errors.py, test_tasks.py — one file per sub-API, covering request shape (method/URL/body) and response parsing, plus the validation-error paths (list_history requiring external_id when task_name is given; sync requiring include_errors or include_task_updates; errors.list requiring external_id when task is given).
  • test_api_client.py — added TestRetryableEndpoints cases for integrations, integrations/config, integrations/actions*.

Why it changed

  • Related issue: EDG-827
  • Related docs / discussion: follows the same httpx_mock + get_url()/jsgz_load() pattern used by the existing simulators test suite.

What to focus on during review

  • These tests exercise the API strictly through cognite_client.integrations.* / async_client.integrations.* (never by instantiating the sub-API classes directly), matching how every other API module in this SDK is tested.
  • The validation-error tests (ValueError on missing external_id/include_errors/include_task_updates combinations) are the only behavior-defining tests here — everything else is round-trip request/response verification.

Test evidence

  • pytest tests/tests_unit/ -q → 6,669 passed, 8 failed (pre-existing, unrelated: missing geopandas/sympy in the local dev environment, same failures present on master), 6 skipped
  • Confirmed this branch reconstructs the original (unsplit) integrations-part2-core-api branch byte-for-byte (git diff against it is empty)
  • ruff check / ruff format --check → clean

Risks and unknowns

Rollout and rollback

  • N/A — test-only change, no runtime behavior affected. Revert is a straight revert of this commit.

Checklist

  • Self-reviewed the diff
  • Tests added or updated (or N/A with reason)
  • Docs updated (or N/A) — N/A, test-only change
  • No secrets, credentials, or PII committed
  • Breaking changes called out above and communicated to affected teams — N/A, no breaking changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds comprehensive unit tests for the integrations API, covering actions, configuration, errors, integrations, and tasks. It also updates the API client tests to register the new integration endpoints as retryable or non-retryable. I have no feedback to provide as there are no review comments.

@vikramlc-cognite
vikramlc-cognite marked this pull request as draft September 7, 2026 12:20
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.22%. Comparing base (6fdd3ea) to head (eb9d750).

Additional details and impacted files
@@                          Coverage Diff                           @@
##           integrations-part2.1-core-api-impl    #2821      +/-   ##
======================================================================
+ Coverage                               93.02%   93.22%   +0.19%     
======================================================================
  Files                                     533      538       +5     
  Lines                                   54352    54531     +179     
======================================================================
+ Hits                                    50562    50835     +273     
+ Misses                                   3790     3696      -94     
Files with missing lines Coverage Δ
...ts_unit/test_api/test_integrations/test_actions.py 100.00% <100.00%> (ø)
...sts_unit/test_api/test_integrations/test_config.py 100.00% <100.00%> (ø)
...sts_unit/test_api/test_integrations/test_errors.py 100.00% <100.00%> (ø)
...it/test_api/test_integrations/test_integrations.py 100.00% <100.00%> (ø)
...ests_unit/test_api/test_integrations/test_tasks.py 100.00% <100.00%> (ø)
tests/tests_unit/test_api_client.py 99.72% <ø> (ø)

... and 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Unit tests (mocked HTTP) for IntegrationsAPI's CRUD methods and the
Tasks, Errors, Config, and Actions sub-APIs added in the previous PR,
plus retry-idempotency coverage in test_api_client.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vikramlc-cognite
vikramlc-cognite force-pushed the integrations-part2.2-core-api-tests branch from c3eecdf to eb9d750 Compare September 7, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants